﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CarLoanSystem.Entity;
using CarLoanSystem.DAL;
using CarLoanSystem.Comman;

namespace CarLoanSystem.Web.pageSignOn
{
    public partial class SignOn : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.txtUsername.Focus();
            Session["userinfo"] = "";
            Session["role"] = "";
        }

        public string user;
        protected void btnLogin_Click(object sender, ImageClickEventArgs e)
        {
            CustomerItem item = CustomerInfoDAL.Login(this.txtUsername.Text, this.txtPassword.Text);
            if (item == null)
            {
                AjaxScript.AlertMsg("username หรือ password ผิด", this);
            }
            else 
            {
                Session["Member"] = item;
                Response.Redirect("~/page/Main/MainPage.aspx");
            }
           
        }

        protected void btnClear_Click(object sender, ImageClickEventArgs e)
        {
            this.txtUsername.Text = "";
            this.txtPassword.Text = "";
            this.txtUsername.Focus();
        }
    }
}